package
{
	public class Flow
	{
		/*
		public static var Block:Boolean = false;
		
		public static function InOrder(... args):void {
			
		}
		
		public static function Advance():void {
			
		}
		*/
		
		/******* Queueing for in-order execution *******/
		private static var queue:Array = new Array();
		private static var entrant:Boolean = false;
		
		/* Perform asynchronous operation in order. */
		public static function Ord(op:Function):void {
			if ((entrant == true) || (queue.length > 0)) {
				queue.push(op);
			} else {
				entrant = true;
				op.call();
			}
		}
		
		/* Release the next queued operation, if there is one. */
		public static function Next():void {
			entrant = false;
			if (queue.length > 0) {
				entrant = true;
				(queue.shift() as Function).call();
			}
		}
		
		
		/*
		private static var queue:Array = new Array();
		private static var entrant:Boolean = false;
		*/
		
		/* Perform asynchronous operation in order. */
		/*
		public static function Ord(op:Function):void {
			if ((entrant == true) || (queue.length > 0)) {
				queue.push(op);
			} else {
				entrant = true;
				op.call();
			}
		}
		*/
		
		/* Release the next queued operation, if there is one. */
		/*
		public static function Next():void {
			entrant = false;
			if (queue.length > 0) {
				entrant = true;
				(queue.shift() as Function).call();
			}
		}
		*/
	}
}